Part 2: Consider When Migrating Xamarin.Forms to .NET MAUI

您所在的位置:网站首页 migrate is installed Part 2: Consider When Migrating Xamarin.Forms to .NET MAUI

Part 2: Consider When Migrating Xamarin.Forms to .NET MAUI

2023-04-08 21:27| 来源: 网络整理| 查看: 265

What steps should you take when preparing to migrate your app from Xamarin.Forms to .NET MAUI? This list will help you think it through.

In the previous post, we reviewed the pros and cons of migrating our code from Xamarin.Forms to .NET MAUI. In this post we will highlight the major points of planning the migration.

In short, these are the things that are good to consider before starting:

Prepare your environmentReview DataModelsChoose a navigation patternAnalyze third-party librariesBenefit from Azure supportTake a minute to think about Windows UI and the desktop experienceLeave customization until the endStay tuned for the next posts where we will review more API changes and some manual work you need to do in renaming APIs1. Install VS 2022 and Set up Your .NET MAUI Environment

This is a basic but very important step for our process. Installing the latest version of VS 2022 or VS for Mac should set up most all that you need to start your development. Still, for Mac there are some additional requirements, such as:

A Mac that is compatible with the latest version of Xcode. For more information, see Apple’s minimum requirements documentation.The latest version of Xcode.An Apple ID and paid Apple Developer Program enrollment. An Apple ID is required to deploy apps to devices, and to submit apps to the Apple Store.

Note: Full steps can be found on Microsoft’s documentation site—check it for latest updates.

Once you are ready, you will be able to start with a basic .NET MAUI app—which is a great starting point. Create one and have a look at it as we will use it as reference during the migration.

Another important tool that we will use during the migration is .NET Update Assistant. You can now download it too from VS MarketPlace, but I still recommend it to use it via cmd as the extension has some limitations. You can install it simply with the following command:

dotnet tool install -g --add-source "https://api.nuget.org/v3/index.json" --ignore-failed-sources upgrade-assistant

2. Review Data Models and Patterns of Your Existing App

Now is a good time to review how the code separation is handled in your app and to decide whether to migrate it directly or consider changing it as .NET MAUI support improved MVVM support and a new MVU pattern is also added.

If you already using MVVM in your app, it is more natural to stay on it. It’s a great and widely used pattern. But if this is the case, there are some other important notes to consider if you use one of the popular MVVM helper libraries:

MVVM cross is popular for Xamarin, but currently not supported with .NET MAUI. As an alternative, you can rely purely on the built-in MVVM MAUI support or consider using MVVM Community toolkit.

3. Choose a Navigation Pattern

.NET MAUI supports great shell navigation and every sample .NET MAUI app contains a template ready to start with. If you do not use shell navigation, consider this change as a step in the migration plan: .NET MAUI Shell navigation - .NET MAUI | Microsoft Learn. Using basic page navigation is also an option: FlyoutPage, TabbedPage and NavigationPage.

4. Check Whether Your Third-Party Libraries Support .NET MAUI

This is an important step in preparation. Check this in advance and find alternatives of your APIs if not.

One such library is Progress Telerik UI for Xamarin—don’t worry, we’ve got you covered. You can replace it safely with Telerik UI for .NET MAUI. (Download it here!)

5. Azure Support

Where is your data service published? What kind of login authentication do you have? Take a step to consider the usage of Azure for all of these if you still haven’t.

If your mobile already uses Azure, an important note is that Microsoft.WindowsAzure.MobileServices are now rebranded as Microsoft Datasync.Client. Read a full explanation and sample in Microsoft docs: Build a .NET MAUI app with Azure Mobile Apps | Microsoft Learn—or in one of our next posts where we will integrate Telerik .NET MAUI app and Azure mobile .馃槉

So plan migration of Azure references as a separate step and read resources before that.

6. Take a Minute to Consider the Future of Windows Support

With .NET MAUI Windows, support is focused more on the desktop side, so now is time to consider whether you need to polish the UI of the Windows version to be a little better for your desktop users. If Windows is not a priority for you, you can still leave this part for debugging and easy development purposes.

7. Have You Used Custom Renderers to Customize the Native Controls?

Consider their migration to .NET MAUI handlers by preparing yourself with handlers architecture and following our series where we will describe the options here—should we use the handlers architecture or migrate the renderers directly?

8. Follow Us for More Guidance

There are some API changes when migrating from Xamarin.Forms to .NET MAUI. We will review them in the next two posts explaining how we managed to migrate our ERP app.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3